#!/usr/bin/perl

use Test;
BEGIN { plan tests => 2}

$basedir = $0;  $basedir =~ s|(.*)/[^/]*|$1|;

# Remove any leftover programs from prior failed runs.
system("rm -f $basedir/true");

# Set up a program with the denied type for this domain.
system("cp /bin/true $basedir/true");
system("chcon -t test_execute_notrans_denied_t $basedir/true");

# Verify that test_execute_notrans_t cannot execute the denied type.
$result = system("runcon -t test_execute_notrans_t -- bash -c $basedir/true 2>&1");
ok($result); #this should fail

# Set up a program with the allowed type for this domain.
system("chcon -t test_execute_notrans_allowed_t $basedir/true");

# Verify that test_execute_notrans_t can execute the allowed type.
$result = system("runcon -t test_execute_notrans_t -- bash -c $basedir/true 2>&1");
ok($result,0); #this should pass

# Cleanup.
system("rm -f $basedir/true");

exit;
